package com.zy.imagineCommunity;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * @SpringBootApplication来标注一个主程序类，说明是一个springboot应用
 */
@SpringBootApplication
public class MainApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext configurableApplicationContext = SpringApplication.run(MainApplication.class);
        Environment environment = configurableApplicationContext.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = environment.getProperty("server.port");
        String contextPath = environment.getProperty("server.servlet.context-path");
        System.out.println(
                "                                          \n" +
                "            项目启动成功                    \n" +
                " ____  _____  ____  _____  _____          \n" +
                "(_ (_`|_   _|/ () \\ | () )|_   _|        \n" +
                ".__)__) |_| /__/\\__\\|_|\\_\\  |_|       \n" +
                "                                          \n" +
                "前台访问地址:http://" + ip + ":" + port + contextPath +"/index\n" +
                "后台访问地址:http://" + ip + ":" + port + contextPath +"/managementIndex\n"
        );
    }

}
